import ACT from '../pages/actionType'

const initState = {
  errorRequest: {},
  commonUser: {}
}

const reduce = {
  [ACT.FAILURE]: (state, { type, payload, meta }) => ({
    ...state,
    errorRequest: {
      status: false,
      errorMsg: '请求错误！',
      error: payload.error
    }
  }),
  [ACT.COMMON_USER_GET]: (state, { type, payload, meta }) => ({
    ...state,
    commonUser: {
      ...state.user,
      name: payload.data.name
    }
  })
}

export default { initState, reduce }
